export function createShader(gl,type,source) {
    const shader = gl.createShader(type)
    gl.shaderSource(shader,source)
    gl.compileShader(shader)
    const success = gl.getShaderParameter(shader,gl.COMPILE_STATUS)
    if(success){
        return shader
    }
    gl.deleteShader(shader)
}

export function createProgram(gl,vShader,fShader) {
    const program = gl.createProgram()
    gl.attachShader(program,vShader)
    gl.attachShader(program,fShader)
    gl.linkProgram(program)
    const success = gl.getProgramParameter(program,gl.LINK_STATUS)
    if(success){
        return program
    }
    gl.deleteProgram(program)
}